# -*- coding: utf-8 -*-
# @Time    : 2021/3/31 19:00
# @Author  : 夏思毅
# @Email   : 2739124228@qq.com
# @File    : 三乐购物系统.py
# @Software: PyCharm

# import pygame
# # 音乐的路径
# file=r'F:\CloudMusic\折戸伸治 - 日々の遑.mp3'
# # 初始化
# pygame.mixer.init()
# # 加载音乐文件
# track = pygame.mixer.music.load(file)
# # 开始播放音乐流
# pygame.mixer.music.play()



print(('\033[1;35m"欢迎来到暮仙州琅琊阁" \033[0m').center(80,"="))

#登录界面


# 登录及注册提示
# 可登录用户
swordsmanlist = {'风清扬': '123456', '李牧之': '123456', '1': '1', '吴少侠': '我是大傻逼'}
# 商品信息
# goodslist = {'g1':{'名字':'黑虎经','价格':'1560'},
#              'g2':{'名字':'石磐大法','价格':'1877'},
#              'g3':{'名字':'清风剑','价格':'2560'},
#              'g4':{'名字':'悍山拳','价格':'1045'}}
goodslist = {'g1':{'名字':'黑虎经','价格':'1560','stock':'2'},
             'g2':{'名字':'石磐法','价格':'1877','stock':'3'},
             'g3':{'名字':'清风剑','价格':'2560','stock':'6'},
             'g4':{'名字':'悍山拳','价格':'1045','stock':'5'}}
# 已购信息
buylist = {}
count = 0

def ex(input):
    if input == 'exit':
        for i, j in buylist.items():
            print("编号:", i)
            print("商品名称：", j['名字'])
            print("商品价格：", j['价格'])
            print("已购数量：", j['count'])
        print('腰包里还有',money)
        exit()
    else:
        pass


while 1:

    yw = input("登入 申请（别的不行嗷）：")
    while yw =="申请":
        # 实现注册功能
        namelogin = input("烦请留下信物：")
        passwordlogin = input("亦请留下信诀：")
        swordsmanlist.update({f'{namelogin}':f'{passwordlogin}'})
        print(('\033[1;35m申请成功 \033[0m').center(80,'*'))
        # print(('\033[1;36m温馨提示：江湖险恶，为了少侠您的安全，还请出示信物及信诀。 \033[0m').center(69, "*"))
        # while 1:
        #     name = input("信物：")
        #     if name in swordsmanlist.keys():
        #         password = input("信诀：")
        #         if password == swordsmanlist[name]:
        #             # 登录功能
        #             print(f"欢迎{name}入阁".center(80, '+'))
        #             break
        #         else:
        #             print("再想想,非此信诀")
        #     else:
        #         print("请三思,非此信物")
        break

            # print(swordsmanlist)
    while yw == '登入':
        print(('\033[1;35m温馨提示：江湖险恶，为了少侠您的安全，还请出示信物及信诀。 \033[0m').center(69, "*"))
        while 1:
            name = input("信物：")
            if name in swordsmanlist.keys():
                password = input("信诀：")
                if password == swordsmanlist[name]:
                # 登录功能
                    print((f'\033[1;36m欢迎{name}入阁 \033[0m').center(80,'+'))
                    break
                else:
                    print("再想想,非此信诀")
            else:
                print("请三思,非此信物")
        break
    else:
        # print("少侠请认字！")
        continue

    while 1:
        money = float(input("可否告知本次所携带灵石数量："))
        ex(input("输入洋文exit可退出："))
        if int(money) < 1041:
            print("少侠盘缠不够，还请回")
            exit()

        while 1:
                print("少侠若想购买商品，还请消费1颗灵石".center(73, '-'))
                print("少侠若想查看已购买商品，还请消费2颗灵石".center(71, '-'))
                print("少侠若想查看商品信息，还请消费10颗灵石".center(72,'-'))
                give = input("请投放灵石：")
                ex(input("输入洋文exit可退出："))
                if int(give) == 10:
            # 查看商品信息
                    money-=10
                    for i,j in goodslist.items():
                        print(f"编号：{i}",f"名字：{j['名字']}",f"价格：{j['价格']}",f"库存：{j['stock']}")
                    ex(input("输入洋文exit可退出："))
                if int(give) == 1:
                        # 购买功能
                    money -= 1
                    choice = input("欢迎选购,请输入购买商品编号:")
                    gc=goodslist[choice]

                    while choice in goodslist.keys():
                        money -= float(f"{goodslist[choice]['价格']}")

                        if choice  in buylist:
                            bc = buylist[choice]
                            bc['count'] = int(bc['count'])+int(1)
                            # 购买数量
                            gc['stock'] = int(gc['stock'])-1
                        #     库存
                        else:
                            count +=1

                            gc['count'] =count
                            # 库存
                            gc['stock'] = int(gc['stock'])-1
                            # 库存
                            buylist[choice]=gc
                        print(f"您已成功购买{goodslist[choice]['名字']}")
                        ex(input("输入洋文exit可退出："))
                        # print(goodslist[choice])
                        break
                    else:
                        print("没有该种商品，请重新选择。")
                if int(give) == 2:
                    money -= 2
                    if buylist:
                        print(('\033[1;36m已购信息 \033[0m').center(100, "*"))
                        for i, j in buylist.items():
                            print("编号:", i, end=' ')
                            print("商品名称：", j['名字'], end=' ')
                            print("商品价格：", j['价格'], end=' ')
                            print("已购数量：", j['count'])
                        ex(input("输入洋文exit可退出："))
                    else:
                        print("暂未购买任何商品")
                        print("剩余灵石：", money)




#回收站
# for key in "$@"
# do
#     cp -r "$@" /hsz
#     rm -ir "$@"
# done
# echo "已删除，备份文件在/hsz目录中"

